﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YunHan.BuShi123.BLL;
using YunHan.BuShi123.Model;

public partial class admin_Info_List : AdminBasePage
{
    public string ContextString { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["action"] != null && Request["action"] == "edit")
            {
                Bind();
            }
        }
    }

    private void Bind()
    {
        int ID = Convert.ToInt32(Request["ID"]);
        Info_Model Side = Info_BLL.GetModelByKeyFiled(ID);
        ContextString = Side.context;

        FineUI.PageContext.RegisterStartupScript(String.Format("updateEditor({0});", FineUI.JsHelper.Enquote(Side.context)));
    }


    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Request["action"] != null && Request["action"] == "edit")
        {
            Info_Model S = new Info_Model()
            {
                ID = Convert.ToInt32(Request["ID"]),
                context = Request.Form["Editor1"],
                sort = 1,
                title = ""
            };

            string Where = "context=@context";

            int Result = Info_BLL.Update(Where, "ID=@ID", S);

            if (Result > 0)
            {
                
                FineUI.PageContext.RegisterStartupScript(FineUI.ActiveWindow.GetHideRefreshReference());
                // FineUI.Alert.Show("更新成功", "", FineUI.MessageBoxIcon.Information, "location='list.aspx'");
            }
            else
            {
                FineUI.Alert.Show("更新失败", FineUI.MessageBoxIcon.Error);
            }
        }
    }
}